package tw.com.test01;

import java.util.ArrayList;
import java.util.Collection;


import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

public class Condition extends Activity {


	private TextView title;
	private Button btnStart;
	private TextView txtYear;
	private TextView txtLevel;
	
	String[] years;

	String[] levels;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_condition);

		loadViews();
		addListeners();		
	}
	void loadViews(){
		title = (TextView) findViewById(R.id.txtTitle);
		getInstent();

		btnStart = (Button) findViewById(R.id.btnStart);
		txtYear = (TextView) findViewById(R.id.txtYear);
		txtLevel = (TextView) findViewById(R.id.txtLevel);


 
		//title.setText("text");
	}
	void getInstent(){

		Bundle bundle = this.getIntent().getExtras();
		title.setText(bundle.getString("subject"));
		
	}
    MultiChoiceDialog YearDialog,LevelDialog;
    void addListeners(){
    	btnStart.setOnClickListener(btnStart_OnClick);
		txtYear.setOnClickListener(txtYear_OnClick);
 			years= new String[]{"90","91","92","93","94","95","96","97","98","99","100","101"};
    	YearDialog=new MultiChoiceDialog(Condition.this, txtYear, "Year", years);
    	YearDialog.selectAll();

		txtLevel.setOnClickListener(txtLevel_OnClick);
		levels= new String[]{"三等","四等","五等"};
		LevelDialog=new MultiChoiceDialog(Condition.this, txtLevel, "等級", levels);
		LevelDialog.selectAll();
    }



    private TextView.OnClickListener txtYear_OnClick=new Button.OnClickListener(){
 		@Override
 		public void onClick(View v) {
 			YearDialog.show();
 		}
    };

    private TextView.OnClickListener txtLevel_OnClick=new Button.OnClickListener(){
 		@Override
 		public void onClick(View v) {
 			LevelDialog.show();
 		}
    };

    private Button.OnClickListener btnStart_OnClick=new Button.OnClickListener(){
 		@Override
 		public void onClick(View v) {
			title.setText("Title OnClick");
			
    		String val;
    		Intent intent = new Intent();
    		
    	//	val=((TextView)v).getText().toString();
    		
    		intent.setClass(Condition.this, Exam.class );
    		
    		//intent.putExtra("test", val);
    		startActivity(intent); 
    	}
    };
}
